home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 25
/
Aminet 25 (1998)(GTI - Schatztruhe)[!][Jun 1998].iso
/
Aminet
/
dev
/
amos
/
AMOS0398.lzh
/
AMOSLIST
/
000299_amos-request@svcs1.digex.net_Fri Mar 27 19:35:21 1998.msg
< prev
next >
Wrap
Text File
|
1998-04-01
|
5KB
|
136 lines
>From amos-request@svcs1.digex.net Fri Mar 27 19:35:21 1998
Received: from svcs1.digex.net (svcs1.digex.net [204.91.197.224])
by pony-1.mail.digex.net (8.8.8/8.8.8) with ESMTP id TAA02632
for <mcox@access.digex.net>; Fri, 27 Mar 1998 19:35:21 -0500 (EDT)
Received: (from daemon@localhost)
by svcs1.digex.net (8.8.5/8.8.5) id PAA04800
for amos-out; Fri, 27 Mar 1998 15:57:37 -0500 (EST)
Received: from pony-1.mail.digex.net (pony-1.mail.digex.net [204.91.241.5])
by svcs1.digex.net (8.8.5/8.8.5) with ESMTP id PAA04791
for <amos-list@svcs1.digex.net>; Fri, 27 Mar 1998 15:57:35 -0500 (EST)
Received: from mail-in1.inet.tele.dk (mail-in1.inet.tele.dk [194.182.148.158])
by pony-1.mail.digex.net (8.8.8/8.8.8) with SMTP id PAA10919
for <amos-list@access.digex.net>; Fri, 27 Mar 1998 15:57:34 -0500 (EST)
Received: (qmail 23816 invoked from network); 27 Mar 1998 20:57:31 -0000
Received: from post10.tele.dk (194.239.134.174)
by mail-in1.inet.tele.dk with SMTP; 27 Mar 1998 20:57:31 -0000
Received: from post10.tele.dk ([194.239.152.57]) by post10.tele.dk
(Netscape Mail Server v2.02) with SMTP id AAA9610;
Fri, 27 Mar 1998 21:57:28 +0100
From: Rune Zedeler <rzedeler@post10.tele.dk>
To: Declan_Gorman@modusmedia.com
CC: AMOS List <amos-list@access.digex.net>
Date: Fri, 27 Mar 1998 20:50:43 +0100
Message-ID: <yam7390.2189.139021968@post10.tele.dk>
In-Reply-To: <00019BD3.eval@modusmedia.com>
X-Mailer: YAM 1.3.5 [040] - Amiga Mailer by Marcel Beck
Subject: Re: Sorting Problem
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by svcs1.digex.net id PAA04796
Status: O
X-Status:
On 16-Mar-98, Declan_Gorman@modusmedia.com wrote:
> My program has a memory bank which consists of 128 blocks of memory,
> each 256k in size. Each memory block has a name and category and I
> want to be able to sort the bank by either.
This should do it:
<CUT>
' Needs sorting string to be located in S_STR$(0) to S_STR$(NUM-1)
' ( ... I don't know how to pass arrays to procs...)
_SORT[128,256*1024,BANK_NUMBER,NUMBER_OF_ITEMS_IN_ARRAY,UNUSED_BANK]
Procedure _SORT[NUM,SIZ,BNK,ARR_SIZ,TMP_BNK]
Shared S_STR$()
Reserve As Work TMP_BNK,SIZ
Dim CUR(NUM-1),OLD(NUM-1)
'Add number of item to the end of the string
For I=0 To NUM-1 : S_STR$(I)=S_STR$(I)+Hex$(I,4) : Next I
'ensure that unused items in array will be placed first after sorting
If ARR_SIZ>NUM
For I=NUM To ARR_SIZ-1 : S_STR$(I)='' : Next I
End If
Sort S_STR$(0)
'move sorted items FROM last TO first in array
For I=0 To NUM-1 : S_STR$(I)=S_STR$(I+ARR_SIZ-NUM) : Next I
'At this point the first NUM indexes in S_STR$() contains sorted
'data - followed by the original position in the array.
For I=0 To NUM-1 : CUR(I)=I : OLD(I)=I : Next I
'CUR(ORIGINAL_POS) contains CURRENT_POS
'OLD(CURRENT_POS) contains ORIGINAL_POS
For I=0 To NUM-1
'OLDI=what index index I had before sorting.
OLDI=Val(Right$(S_STR$(I),5))
'J=Current position of block
J=CUR(OLDI)
Print OLDI,J
S_STR$(I)=Left$(S_STR$(I),Len(S_STR$(I))-5)
'swap blocks:
If I<>J
Copy Start(BNK)+I*SIZ,Start(BNK)+(I+1)*SIZ To Start(TMP_BNK)
Copy Start(BNK)+J*SIZ,Start(BNK)+(J+1)*SIZ To Start(BNK)+I*SIZ
Copy Start(TMP_BNK),Start(TMP_BNK)+SIZ To Start(BNK)+J*SIZ
Swap CUR(OLD(I)),CUR(OLD(J))
Swap OLD(I),OLD(J)
End If
Next I
Erase TMP_BNK
End Proc
<CUT>
Quick tech explanation (hmmm, how it works, eh):
I use the internal AMOS sort cmd. But before sorting I add the hex number to
the end of the strings. So if the strings are:
Hi
There
!!!
then I add like this:
Hi$0000
There$0001
!!!$0002
After sorting (using "Sort") it is:
!!!$0002
Hi$0000
There$0001
- and I can use the numbers to move around in the bank.
I reserve a temp bank on the size of one block (that is 256k)
As I do not have 32MB of ram I have not been able to test it with your amount
of memory. It moves the memory three times. That is: It will move 96MB of
data! So it'll probably use a small amount of time.
Just write a letter to the list (send a copy to me personally, as I am only
very seldom at home and therefore incidentally skips some letters in the
mailinglists) if you have questions.
--
/�\ __ __ /�����\ _ Rune Zedeler
________/ /// \\__/ \\\ ---/ \�-_ Peter R�rdams Vej 19
\ / //�| \\/ ||�\ \\�������������� �-_ 2800 Lyngby
) / // | \ ` / || \ \\ Lemmus of Efreet - Denmark
/ / �����\\|\-'/ /����� \\____________ _-�
�����\------'/||��| \------'/ /_-� rzedeler@post10.tele.dk
������\-'/ \-'/������ � Tel: +45-45871730
�� ��